<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<jsp:include page="/jsp/admin/common.jsp" />
<jsp:include page="/jsp/formHead.jsp" />
<script type="text/javascript">
$().ready(function(){

	/*页面为修改状态，对页面数据进行初始化*/
	var status = "${status}";
	if(status == "E"){	//编辑状态
		initData();
	}
	
	/*返回按钮事件*/
	$("#backButton").click(function(){
		location.href = basePath + "jsp/admin/user/user_list.jsp";
	});

	var $form = $("#form_add");

	/*表达验证配置*/
	$form.validate({
		rules: {
			name : "required",
			email : {
				required : true,
				email : true
			}
		}
	});

	/*表单提交前操作*/
	$form.submit(onSubmit);
});

function onSubmit(){

	var url = basePath + "admin/member_save.do",
		data = {
			id : $("input[name='id']").val() || 0,	//ID
			name : $("input[name='name']").val(),	//名称
			email : $("input[name='email']").val()	//email
		},
		callback = function(_result){	//回调函数
			var url = encodeURI(basePath + "jsp/admin/vip/vip_list.jsp?type="+ _result.type +"&content=" + _result.content);
			location.href = url;
		};

	doPost("#form_add", url, data, callback,"json", true);

	return false;
}
</script>
</head>
<body>
	<div class="path">
		<a href="">首页</a> &raquo; <c:if test="${param.status == \"A\" }">添加会员</c:if><c:if test="${status == \"E\" }">修改会员</c:if>
	</div>
	<form id="form_add" method="post" action="<%=basePath %>admin/user_save.do">
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField">*</span>名称:
				</th>
				<td>
					<input type="hidden" name="id" value="${entity.id }" />
					<input type="text" name="name" class="text" maxlength="200" value="${entity.name }"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>E-mail:
				</th>
				<td>
					<input type="text" name="email" class="text" maxlength="200" value="${entity.email }"/>
				</td>
			</tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="确定" />
					<input type="button" id="backButton" class="button" value="返回"/>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>